//存取器  让我们有效的控制对象中成员的访问 通过getters 和setters进行操作
(()=>{
    class Person{
        firstName:string
        lastName:string
        constructor(firstName:string,lastName:string) {
            this.firstName = firstName
            this.lastName = lastName
        }
        get fullName() {
            return this.firstName +'__'+this.lastName
        }
        set fullName(val) {
            let names = val.split('_')
            this.firstName = names[0]
            this.lastName =names[1]
        }
    }
    const person = new Person('东方','不败')
    console.log(person);
    console.log(person.fullName);
    person.fullName = '诸葛_孔明'
    console.log(person.fullName);
    
})()